<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://jakarta.apache.org/taglibs/string-1.1" prefix="str" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<fmt:setBundle basename="labels"/>
<portlet:defineObjects/>
<jsp:include flush="true" page="header.jsp" />
<c:if test="${!emptyBean.def.newDisabled}">
	<!-- New -->
	<form action="<portlet:actionURL />">
		<input type="hidden" name="action" value="NEW"/>
		<input type="submit" value="<fmt:message key="label.new"/>" class="crud">
	</form>
</c:if>
<jsp:include flush="true" page="browseFilter.jsp" />
<!-- Browse -->
<table cellpadding="0" cellspacing="0" width="100%" class="crud" >
<c:forEach var="bean" items="${beans}" end="0">
	<!-- header -->
	<tr>
	<c:forEach var="field" items="${bean.browsableFields}">
		<th>
			<c:out value="${field.def.label}"/>
		</th>
	</c:forEach>
		<th></th>
<c:if test="${!emptyBean.def.editDisabled}">		
		<th></th>
</c:if>
<c:if test="${!emptyBean.def.removeDisabled}">		
		<th></th>
</c:if>		
	</tr>
</c:forEach>	

<c:forEach var="bean" items="${beans}" varStatus="status">
	<c:choose>
	   <c:when test='${(status.index)%2 eq 0}'>
	    <c:set var="rowColor" value="even" scope="page"/>
	  </c:when>
	  <c:otherwise>
	    <c:set var="rowColor" value="odd" scope="page"/>
	  </c:otherwise>
	</c:choose>
	<tr class="<c:out value="${rowColor}"/>">
	<c:forEach var="field" items="${bean.browsableFields}">
<c:set var="field" value="${field}" scope="request"/>
		<td class="<c:out value="${rowColor}"/>">
<jsp:include flush="true" page="viewer.jsp" />
		</td>
	</c:forEach>
		<form action="<portlet:actionURL />">
		<td width="1%" class="<c:out value="${rowColor}"/>">
			<input type="hidden" name="action" value="VIEW" />
			<c:forEach var="id" items="${bean.ids}">
				<input type="hidden" 
					name="<c:out value="${id.def.name}"/>" 
					value="<c:out value="${id.value}"/>"/>
			</c:forEach>
			<input type="submit" value="<fmt:message key="label.view"/>" class="crud">
		</td>	
		</form>
	<c:if test="${!emptyBean.def.editDisabled}">
		<form action="<portlet:actionURL />">
		<td width="1%" class="<c:out value="${rowColor}"/>">
			<input type="hidden" name="action" value="EDIT" />
			<c:forEach var="id" items="${bean.ids}">
				<input type="hidden" 
					name="<c:out value="${id.def.name}"/>" 
					value="<c:out value="${id.value}"/>"/>
			</c:forEach>
			<input type="submit" value="<fmt:message key="label.modify"/>" class="crud">
		</td>
		</form>
	</c:if>		
	<c:if test="${!emptyBean.def.removeDisabled}">		
		<form action="<portlet:actionURL />">
		<td width="1%" class="<c:out value="${rowColor}"/>">
				<input type="hidden" name="action" value="REMOVE" />
				<c:forEach var="id" items="${bean.ids}">
					<input type="hidden" 
						name="<c:out value="${id.def.name}"/>" 
						value="<c:out value="${id.value}"/>"/>
				</c:forEach>
				<input type="submit" 
					value="<fmt:message key="label.delete"/>" 
					onClick="return confirm('<fmt:message key="question.confirm.delete"/>')" 
					class="crud">
		</td>
		</form>
	</c:if>
	</tr>
</c:forEach>
</table>

<jsp:include flush="true" page="browsePaging.jsp" />